package cate.game.play.skill.passive.exp;

import cate.common.table.d.GDSkill;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.SkillActionCtx;
import cate.game.play.skill.effect.SkillEffect;
import cate.game.play.skill.passive.PassiveHandler;

/**
 * 治疗时，如果自身生命百分比低于被治疗目标，则恢复自身攻击120%的生命，同时清除2个负面状态
 */
public class 枯木生花PH extends PassiveHandler {

	private double 恢复系数;

	private int 驱散数量;

	//恢复系数=12000&驱散数量=2
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		恢复系数 = args.getWDouble("恢复系数", 0d);
		驱散数量 = args.getInt("驱散", 0);
	}

	@Override
	public void beforeSkillSettleAsActor(SkillActionCtx action, SkillEffect effect, Fighter target) {
		if (!action.getSkill().cfg.isEffectType(GDSkill.EffectType.治疗)) {
			return;
		}
		if (skill.owner.attr.total().hpCurRate() > target.attr.total().hpCurRate()) {
			return;
		}
		skill.owner.attr.passiveHeal(action, skill.owner.attr.attTotal() * 恢复系数);
		skill.owner.buff.tryDispelBad(action, 驱散数量);
	}
}
